package com.hgl.servlet.admin;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hgl.Const;
import com.hgl.entity.Hgl;
import com.hgl.service.HglService;
import com.hgl.service.impl.HglServiceImpl;

/**<pre>
 * - 
 * ClassName : com.teach.servlet.LoginServlet
 * Author : J.L.Zhou
 * E-Mail : 2233875735@qq.com
 * Date : 2020年8月1日 上午10:17:54
 * Version : 1.0
 * Copyright 2020 jlzhou.top Inc. All rights reserved. 
 * Warning: this content is only for internal circulation of the company. 
 * It is forbidden to divulge it or use it for other commercial purposes.
 * </pre>
 **/
@WebServlet("/login.let")
public class LoginServlet extends HttpServlet {

	private HglService userService = new HglServiceImpl();
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		String userName = request.getParameter("userName");
		String userPwd = request.getParameter("userPwd");
//		System.out.println(request.getSession().getAttribute(Const.CODE_NAME));
//		try{
////			Hgl user = userService.list();
//			request.getSession().setAttribute(Const.LOGIN_USER_SESSION_NAME, user);
////			request.setAttribute("msg", "登录成功");
////			request.setAttribute("href","admin/user-list.let");//根据角色不同,跳转到不同的地方
//			Const.codeVerify(request.getSession(), request.getParameter("code"));
//			System.out.println(request.getParameter("code"));
//			if(user.getRoleCode().equals("admin")){
//				response.sendRedirect(request.getContextPath()+"/admin/");
//			}else{
//				response.sendRedirect(request.getContextPath()+"/");
//			}
//			return ;
//		}catch(UserLockedException ex){
//			ex.printStackTrace();//记调试日志
//			request.setAttribute("error", ex.getMessage());
//		}catch(Exception ex){
//			ex.printStackTrace();//记调试日志
//			request.setAttribute("error", ex.getMessage());
//		}
//		//跳转到视图
//		request.getRequestDispatcher("/msg.jsp").forward(request, response);
		
	}
}
